<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <div id="app">
        {{msg}}
        <input type="text" v-model="msg" />

        <button @click="cancel">销毁</button>
    </div>

    <script src="js/vue.js"></script>
    <script>
        // 生命周期  8
        // 生命钩子函数
       let vm= new Vue({
            el:"#app",
            data:{
                msg:"ok"
            },
            methods: {
                cancel(){
                   this.$destroy() 
                }
            },
            beforeCreate() {
                console.log("vue实例创建之前")
                console.log("el--"+this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
            created() {
                console.log("vue实例创建之之后")
                console.log("el--"+this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)

                // this.msg="ok01"
            },

            beforeMount() { // 挂载之前 vue实例挂载到 div
               console.log("挂载之前")
                console.log(this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
            mounted() { //挂载之后  ajax请求
                console.log("挂载之后")
                console.log(this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
            beforeUpdate() { // 数据或者组件更新之前
                console.log("数据或者组件更新前")
                console.log(this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
            updated() { // 更新之后
                console.log("数据或者组件更新后")
                console.log(this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
            // 被销毁之后的事件 和双向数据绑定没有了
            beforeDestroy() { //销毁了
                console.log("销毁前")
                console.log(this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
            destroyed() {
                console.log("销毁后")
                console.log(this.$el)
                console.log("data--"+this.$data)
                console.log("data.msg--"+this.msg)
            },
        })
    </script>
</body>
</html>